package com.traffic.dao.impl;


import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.traffic.base.DaoSupportImpl;
import com.traffic.dao.UserDao;
import com.traffic.domain.User;
@Repository
@Transactional
public class UserDaoImpl extends DaoSupportImpl<User> implements UserDao {
	@Resource
	private SessionFactory sessionFactory;
	/**
	 * 获取Session
	 * 
	 * @return
	 */
	protected Session getSession() {
		return sessionFactory.getCurrentSession();
	}
	@Override
	public User getById(Long userId) {
		User user = (User) getSession().get(User.class, userId);
		return user;
	}

}
